#!/usr/bin/env gosh
(use srfi-1)
(use sxml.ssax)
(use sxml.sxpath)
(use sxml.serializer)
(use gauche.parseopt)

(define (main args)
  (let-args (cdr args)
      ((option-n "n|node=s" #f)
       . files)
    (unless option-n (print "usage: cat -n=XPATH") (exit 1))
    (srl:sxml->xml `(cat ,@(append-map (sxpath option-n)
					(map (cut call-with-input-file <> (cut ssax:xml->sxml <> '()))
					     files)))
		   (current-output-port)))
  (exit 0))

